	package co.edu.unal.satacredito.database.administration.ejb;

import java.net.UnknownHostException;
import java.util.Date;
import java.util.List;

import javax.ejb.Stateless;

import co.edu.unal.satacredito.database.administration.exceptions.DAOException;
import co.edu.unal.satacredito.database.administration.singleton.SingletonDataStore;
import co.edu.unal.satacredito.database.connection.TransactionDatastoreFactory;
import co.edu.unal.satacredito.database.dao.NotSyntaxTransactionMongoDao;
import co.edu.unal.satacredito.database.dao.TransactionMongoDao;
import co.edu.unal.satacredito.database.entity.Transaction;

import com.mongodb.MongoException;

/**
 * Session Bean implementation class MonitorDaoEJB
 */
@Stateless
public class TransactionDaoEJB implements TransactionDaoEJBLocal,
		TransactionDaoEJBRemote {

	private TransactionMongoDao daoT;

	/**
	 * Default constructor.
	 * 
	 * @throws DAOException
	 */
	public TransactionDaoEJB() throws DAOException {
		this.daoT = new TransactionMongoDao(SingletonDataStore.getInstance()
				.getDataStore());
	}

	public List<Transaction> findTransactionIdentificationByDate(Date initDate,
			Date endDate) throws DAOException {
		try {
			return daoT.findFailedByDateRangeAndIssueNin(initDate, endDate);
		} catch (Exception e) {
			throw new DAOException(e.getMessage());
		}
	}

	public List<Transaction> findTransactionCardByDate(Date initDate,
			Date endDate) throws DAOException {
		try {
			return daoT.findFailedByDateRangeAndIssueCard(initDate, endDate);
		} catch (Exception e) {
			throw new DAOException(e.getMessage());
		}
	}

}
